#include <cmath>
#include "typedef.h"
#include "xyz.h"


#ifndef _KUAI_PBC_H_
#define _KUAI_PBC_H_


namespace kuai {

	class PBC {
	public:
		explicit PBC();
		explicit PBC(const RealNumber& a, const RealNumber& b, const RealNumber& c);
		explicit PBC(const RealNumber& a, const RealNumber& b, const RealNumber& c, const RealNumber& alpha, const RealNumber& beta, const RealNumber& gamma);

	public:
		RealNumber a() const {
			return fabs(ax);
		}
		RealNumber b() const {
			return sqrt(bx*bx + by*by + bz*bz);
		}
		RealNumber c() const {
			return sqrt(cx*cx + cz*cz);
		}

		XYZ va() const {
			return XYZ(ax, 0, 0);
		}

		XYZ vb() const {
			return XYZ(bx, by, bz);
		}

		XYZ vc() const {
			return XYZ(cx, 0, cz);
		}

		RealNumber alpha() const {
			return angle(vb(), vc());
		};
		RealNumber beta() const {
			return atan2(cz, cx);
		}
		RealNumber gamma() const {
			return acos(bx/b());
		}
		
		RealNumber volumn() const;
		
		XYZ image(const XYZ& v) const;
		void update(XYZ& v) const;
		void update(RealNumber v[]) const;
		
		void shift(const XYZ& v, int result[3]) const;

	private:
		RealNumber ax, bx, by, bz, cx, cz;
	};

}

#endif

